<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" xmlns:sec="http://www.thymeleaf.org/extras/spring-security">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title th:text="${project.name} + ' - 风险列表'"></title>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.0/dist/css/bootstrap.min.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/css/font-awesome.min.css">
</head>
<body>
    <div class="container mt-4">
        <div class="row mb-3">
            <div class="col">
                <h2 th:text="${project.name} + ' - 风险列表'"></h2>
                <nav aria-label="breadcrumb">
                    <ol class="breadcrumb">
                        <li class="breadcrumb-item"><a th:href="@{/}" class="text-decoration-none">首页</a></li>
                        <li class="breadcrumb-item"><a th:href="@{/project/list}" class="text-decoration-none">项目列表</a></li>
                        <li class="breadcrumb-item"><a th:href="@{/project/{id}(id=${project.id})}" class="text-decoration-none" th:text="${project.name}"></a></li>
                        <li class="breadcrumb-item active" aria-current="page">风险列表</li>
                    </ol>
                </nav>
            </div>
        </div>
        
        <div class="row mb-3">
            <div class="col">
                <div class="card">
                    <div class="card-header d-flex justify-content-between align-items-center">
                        <h5 class="mb-0">项目风险</h5>
                        <div>
                            <a th:href="@{/risk/add(projectId=${project.id})}" class="btn btn-primary">
                                <i class="fa fa-plus"></i> 新增风险
                            </a>
                            <a th:href="@{/project/{id}(id=${project.id})}" class="btn btn-outline-secondary ml-2">
                                <i class="fa fa-arrow-left"></i> 返回项目详情
                            </a>
                        </div>
                    </div>
                    <div class="card-body">
                        <div class="table-responsive">
                            <table class="table table-hover">
                                <thead>
                                    <tr>
                                        <th scope="col">ID</th>
                                        <th scope="col">风险名称</th>
                                        <th scope="col">风险类型</th>
                                        <th scope="col">可能性</th>
                                        <th scope="col">影响度</th>
                                        <th scope="col">优先级</th>
                                        <th scope="col">状态</th>
                                        <th scope="col">责任人</th>
                                        <th scope="col">操作</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <tr th:if="${risks.empty}">
                                        <td colspan="9" class="text-center">暂无风险数据</td>
                                    </tr>
                                    <tr th:each="risk : ${risks}">
                                        <td th:text="${risk.id}"></td>
                                        <td th:text="${risk.title}"></td>
                                        <td>
                                            <span th:if="${risk.type == 1}" class="badge badge-secondary">技术风险</span>
                                            <span th:if="${risk.type == 2}" class="badge badge-info">管理风险</span>
                                            <span th:if="${risk.type == 3}" class="badge badge-warning">商业风险</span>
                                            <span th:if="${risk.type == 4}" class="badge badge-danger">法律风险</span>
                                            <span th:if="${risk.type == 5}" class="badge badge-primary">其他风险</span>
                                        </td>
                                        <td>
                                            <span th:if="${risk.probability == 1}" class="badge badge-light">很低</span>
                                            <span th:if="${risk.probability == 2}" class="badge badge-info">低</span>
                                            <span th:if="${risk.probability == 3}" class="badge badge-secondary">中</span>
                                            <span th:if="${risk.probability == 4}" class="badge badge-warning">高</span>
                                            <span th:if="${risk.probability == 5}" class="badge badge-danger">很高</span>
                                        </td>
                                        <td>
                                            <span th:if="${risk.impact == 1}" class="badge badge-light">很低</span>
                                            <span th:if="${risk.impact == 2}" class="badge badge-info">低</span>
                                            <span th:if="${risk.impact == 3}" class="badge badge-secondary">中</span>
                                            <span th:if="${risk.impact == 4}" class="badge badge-warning">高</span>
                                            <span th:if="${risk.impact == 5}" class="badge badge-danger">很高</span>
                                        </td>
                                        <td>
                                            <span th:if="${risk.priority == 1}" class="badge badge-light">很低</span>
                                            <span th:if="${risk.priority == 2}" class="badge badge-info">低</span>
                                            <span th:if="${risk.priority == 3}" class="badge badge-secondary">中</span>
                                            <span th:if="${risk.priority == 4}" class="badge badge-warning">高</span>
                                            <span th:if="${risk.priority == 5}" class="badge badge-danger">很高</span>
                                        </td>
                                        <td>
                                            <span th:if="${risk.status == 1}" class="badge badge-secondary">已识别</span>
                                            <span th:if="${risk.status == 2}" class="badge badge-primary">已分配</span>
                                            <span th:if="${risk.status == 3}" class="badge badge-info">已计划</span>
                                            <span th:if="${risk.status == 4}" class="badge badge-warning">监控中</span>
                                            <span th:if="${risk.status == 5}" class="badge badge-success">已解决</span>
                                            <span th:if="${risk.status == 6}" class="badge badge-danger">已关闭</span>
                                        </td>
                                        <td th:text="${risk.ownerName != null ? risk.ownerName : '未分配'}"></td>
                                        <td>
                                            <div class="btn-group btn-group-sm">
                                                <a th:href="@{/risk/{id}(id=${risk.id})}" class="btn btn-info">
                                                    <i class="fa fa-eye"></i> 详情
                                                </a>
                                                <a th:href="@{/risk/edit/{id}(id=${risk.id})}" class="btn btn-primary" sec:authorize="hasAnyRole('ADMIN', 'MANAGER')">
                                                    <i class="fa fa-edit"></i> 编辑
                                                </a>
                                                <a th:href="@{/risk-response/add/{id}(id=${risk.id})}" class="btn btn-success">
                                                    <i class="fa fa-plus-circle"></i> 响应
                                                </a>
                                            </div>
                                        </td>
                                    </tr>
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        
        <div class="row mb-3">
            <div class="col">
                <div class="card">
                    <div class="card-header">
                        <h5 class="mb-0">风险概要</h5>
                    </div>
                    <div class="card-body">
                        <div class="row">
                            <div class="col-md-3 mb-3">
                                <div class="card bg-primary text-white">
                                    <div class="card-body text-center">
                                        <h3 th:text="${risks != null ? risks.size() : 0}"></h3>
                                        <p class="mb-0">总风险数</p>
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-3 mb-3">
                                <div class="card bg-warning text-white">
                                    <div class="card-body text-center">
                                        <h3 th:text="${unsolvedCount != null ? unsolvedCount : 0}"></h3>
                                        <p class="mb-0">未解决风险</p>
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-3 mb-3">
                                <div class="card bg-success text-white">
                                    <div class="card-body text-center">
                                        <h3 th:text="${solvedCount != null ? solvedCount : 0}"></h3>
                                        <p class="mb-0">已解决风险</p>
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-3 mb-3">
                                <div class="card bg-danger text-white">
                                    <div class="card-body text-center">
                                        <h3 th:text="${highPriorityCount != null ? highPriorityCount : 0}"></h3>
                                        <p class="mb-0">高优先级风险</p>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        
        <div class="row mb-3">
            <div class="col">
                <div class="card">
                    <div class="card-header">
                        <h5 class="mb-0">项目信息</h5>
                    </div>
                    <div class="card-body">
                        <div class="row">
                            <div class="col-md-6">
                                <table class="table table-borderless">
                                    <tbody>
                                        <tr>
                                            <th style="width: 150px;">项目名称:</th>
                                            <td th:text="${project.name}"></td>
                                        </tr>
                                        <tr>
                                            <th>项目经理:</th>
                                            <td th:text="${project.managerName != null ? project.managerName : '未指定'}"></td>
                                        </tr>
                                        <tr>
                                            <th>项目状态:</th>
                                            <td>
                                                <span th:if="${project.status == 1}" class="badge badge-secondary">未开始</span>
                                                <span th:if="${project.status == 2}" class="badge badge-primary">进行中</span>
                                                <span th:if="${project.status == 3}" class="badge badge-success">已完成</span>
                                                <span th:if="${project.status == 4}" class="badge badge-danger">已取消</span>
                                            </td>
                                        </tr>
                                    </tbody>
                                </table>
                            </div>
                            <div class="col-md-6">
                                <table class="table table-borderless">
                                    <tbody>
                                        <tr>
                                            <th style="width: 150px;">开始日期:</th>
                                            <td th:text="${project.startDate != null ? #dates.format(project.startDate, 'yyyy-MM-dd') : '未设置'}"></td>
                                        </tr>
                                        <tr>
                                            <th>结束日期:</th>
                                            <td th:text="${project.endDate != null ? #dates.format(project.endDate, 'yyyy-MM-dd') : '未设置'}"></td>
                                        </tr>
                                        <tr>
                                            <th>创建时间:</th>
                                            <td th:text="${project.createTime != null ? #dates.format(project.createTime, 'yyyy-MM-dd HH:mm') : '-'}"></td>
                                        </tr>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    
    <script src="https://cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@4.6.0/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html> 